package br.elsa.survey.services.listeners.tests;

import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import br.elsa.survey.services.events.SurveyCreatedEvent;
import br.elsa.survey.services.listeners.SurveyEventListener;
import br.elsa.survey.statistics.Statistics;

/**
 * Test class for {@link SurveyEventListener}
 * 
 * @author diego
 * @since 2010-11-19
 */
public class SurveyEventListenerTest {

	/**
	 * Class under test
	 */
	private SurveyEventListener surveyListener;

	@Mock
	private Statistics statistics;

	@Mock
	private SurveyCreatedEvent surveyCreatedEvent;

	@Before
	public void setUp() throws Exception {
		MockitoAnnotations.initMocks(this);
		this.surveyListener = new SurveyEventListener(statistics);
	}

	@Test
	public void onSurveyCreatedShouldLoadStatisticsInformation() {

		surveyListener.onSurveyCreated(surveyCreatedEvent);
		verify(statistics, times(1)).loadStatistics();
	}

}
